<template>
  <wanglei-tree :data="list"></wanglei-tree>
</template>

<script lang="ts">
import { defineComponent, ref, onMounted } from 'vue'

function recursion(path = '0', level = 2) {
  const list = [];
  for (let i = 0; i < 5; i += 1) {
    const nodeKey = `${path}-${i}`;
    const treeNode = {
      nodeKey,
      name: nodeKey,
      children: [],
      hasChildren: true
    };

    if (level > 0) {
      treeNode.children = recursion(nodeKey, level - 1);
    } else {
      treeNode.hasChildren = false;
    }

    list.push(treeNode);
  }
  return list;
}
export default defineComponent({
  setup() {
    const list = ref([])
    onMounted(() => {
      list.value = recursion()
    })

    return {
      list
    }
  }
})
</script>

<style scoped>

</style>
